package com.gimi.cloud.bbp.manage.controller.mall;

import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.enums.ServiceNameConstants;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.dto.mall.MallSuggestDTO;
import com.gimi.cloud.bbp.manage.service.mall.MallSuggestService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/mall/suggest")
public class MallSuggestController {
	@Autowired private MallSuggestService mallSuggestService;

    /**
     * 获取意见反馈信息
     * @param dto
     * @param response
     */
	@RequestMapping("/list")
    @ResponseBody
	public Response list(@RequestBody MallSuggestDTO dto,HttpServletResponse response) {
		Response resp = new Response();
        List<MallSuggestDTO> dtos = mallSuggestService.queryList(dto,true);
        PageInfo<MallSuggestDTO> pageInfo = new PageInfo<>(dtos);
        Map<String,Object> resData = new HashMap<>();
        resData.put(ServiceNameConstants.PAGEDATA_KEY,pageInfo);
        resp.setRes_data(resData);
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
        return resp;
	}
}